import filter.UserAuthFilter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling;

import javax.servlet.Filter;


/**
 * Created by lvdouStart on 2017/6/22.
 */
@SpringBootApplication
@ComponentScan("controller,service,conf,util")
@EnableScheduling
public class Application extends SpringBootServletInitializer{


    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(Application.class);
    }

    public static void main(String[] args) {
        SpringApplication.run(Application.class);
    }


    @Bean
    public FilterRegistrationBean filterRegistration() {
        FilterRegistrationBean registration = new FilterRegistrationBean();
        registration.setFilter(userAuthFilter());//添加过滤器
        registration.addUrlPatterns("/hospitals","/menu","/search/date","/excel",
                "/manning-quotas","/personnel-performance","/medical-balance","/running-guarantee",
                "/family-plan","/medical-business","/general");//设置过滤路径
        registration.setName("userAuthFilter");
        return registration;
    }

    @Bean
    public Filter userAuthFilter(){
        return new UserAuthFilter();
    }

}
